<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
       <script type="text/javascript" src="__PUBLIC__/js/jedate/jedate.js"></script>
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
     
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
         <script src="__PUBLIC__/js/layer.js"></script>
      <style>
	.num,.current{padding:10px;display:inline-block;}
.isShow,.del{cursor:pointer;}

	</style>
	<script>
		//修改举报处理状态
	    function toggleStatus(t,v){
			Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			$.post("{:U('Admin/Posts/editReportStatus')}",{id:v,status:t},function(data,textStatus){
				var json = WST.toJson(data);
				if(json.status=='0'){
					Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
					    location.reload();
				}});
				}else{
					Plugins.closeWindow();
					Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				}
	     	});
	    }
	    //全选和取消
	    $(document).ready(function(){
		    //全选
	        $("#selected").click(function(){
	            $('input[num="list"]').prop('checked',true);
	            $('#cancel').attr('checked',false);
	        });
	        //取消全选
	        $("#cancel").click(function(){
	            $('input[num="list"]').prop('checked',false);
	            $('#selected').attr('checked',false);
	        });
  		});
	</script>
   </head>
  
   <body class='wst-page'>
    	<div style="padding-top: 6px;">
       <div class='wst-tbar'>
       <form method='post' action='{:U("Admin/Posts/postReport")}' autocomplete="off">
       	发布人：<input type='text' id='userName' name='userName' value='{$userName}' style="width:100px;"/>
   		标题：<input type='text' id='title' name='title' value='{$title}' />          
	    内容：<input type='text' id='pcontent' name='pcontent' value='{$pcontent}'/>        
		举报类型：<select name="icontent">
		 <option value="-1">请选择</option>
		 <option  value="1" <if condition="$icontent eq 1">selected="selected"</if>>欺诈</option>
		 <option  value="2"  <if condition="$icontent eq 2">selected="selected"</if>>色情</option>
		 <option   value="3" <if condition="$icontent eq 3">selected="selected"</if>>政治谣言</option>
		 <option  value="4"  <if condition="$icontent eq 4">selected="selected"</if>>常识性谣言</option>
		 <option   value="5" <if condition="$icontent eq 5">selected="selected"</if>>恶意营销</option>
		 <option  value="6"  <if condition="$icontent eq 6">selected="selected"</if>>隐私信息收集</option>
		 <option   value="7" <if condition="$icontent eq 7">selected="selected"</if>>其他（冒名、诽谤、抄袭）</option>
		 <option   value="8" <if condition="$icontent eq 8">selected="selected"</if>>违规声明原创</option>
		 </select> 
         状态：<select name="status">
		 <option  value="-1" <if condition="$status eq -1">selected="selected"</if>>请选择</option>
		 <option  value="1" <if condition="$status eq 1">selected="selected"</if>>已处理</option>
		 <option  value="0" <if condition="$status eq 0">selected="selected"</if>>未处理</option>
		 </select> 
  		<button type="submit" class="btn btn-primary glyphicon glyphicon-search" style="display:inline-block">查询</button> 
		  </form>
       	</div>
       </div>
       <div class="wst-body"> 
        <table class="table table-hover table-striped table-bordered wst-list">
           <thead>
             <tr>
               <th width='40'><input type='checkbox' name='chk' onclick='javascript:WST.checkChks(this,".chk")'/>序号</th>
               <th width='120'>帖子标题</th>
               <th width='150'>帖子内容</th>
               <th width='80'>发布人</th>
               <th width='80'>举报人</th>
               <th width='120'>举报类型</th>
               <th width='80'>举报时间</th>
               <th width='50'>状态</th>
               <th width='80'>操作</th>
             </tr>
           </thead>
           <tbody>
           <volist name="info.root" id="in" key='i'>
             <tr id="tr_{$in.id}">
                <td ><input type='checkbox' class='chk' name='chk_{$in['id']}' value='{$in['id']}'/>{$i}</td>
                <td >{$in.title}</td>
                <td >{$in.pcontent}</td>
                <td>
					<if condition="$in['userName'] neq ''">
               			{$in['userName']}
               			<else />
               			{$in['loginName']}
               		</if>
                </td>
                <td>
                	<if condition="$in['iuserName'] neq ''">
               			{$in['iuserName']}
               			<else />
               			{$in['iloginName']}
               		</if>
               	</td>
                <td >{$in.icontent}</td>
                <td >{$in.itime}</td>
               <td >
               		<div class="dropdown">
                    <if condition="$in['istatus']==0 ">
                      <button class="btn btn-danger dropdown-toggle wst-btn-dropdown"  type="button" data-toggle="dropdown">未处理<span class="caret"></span>
                    </button>
                    <else/>
                      <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">已处理<span class="caret"></span>
                    </button>
                    </if>
                      <ul class="dropdown-menu" role="menu">
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:toggleStatus(1,{$in['id']})">已处理</a></li>
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:toggleStatus(0,{$in['id']})">未处理</a></li>
                     </ul>
                    </div>
               </td>
               <td ><span><a class="btn btn-primary glyphicon" href='{:U("Admin/Posts/toDetail",array("id"=>$in["pid"]))}'>查看</a></span>&nbsp;<span class="btn btn-danger del" data-id="{$in.id}">删除</span></td>
             </tr>
             </volist>
             <tr>
                <td colspan='11'  style="background:none;" >
                <input type='checkbox' name='chk' onclick='javascript:WST.checkChks(this,".chk")'/>全选/取消
		        <input type="button" class="delAll btns" value="批量删除">
		        <input type="button" class="showAll btns" value="批量已处理">
		        <input type="button" class="hideAll btns" value="批量未处理"></td>
             </tr>
             <tr>
                <td colspan='11' align='center'>{$info.pager}</td>
             </tr>
           </tbody>
        </table>
       </div>
   </body>
   <script>
	   //批量删除所选举报记录
	   $('body').on('click','.delAll',function(){
		   var ids = [];
		   $('.chk').each(function(){
			   if($(this).prop('checked'))ids.push($(this).val());
		   })
		   if(ids.length == 0){
	 		   Plugins.Tips({title:'信息提示',icon:'error',content:'请选择要删除的举报!',timeout:1000});
	  		   return;
		   }
       Plugins.confirm({title:'信息提示',content:'您确定要删除所选举报记录吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			$.ajax({
				  type: "POST",
				  url: "{:U('Posts/delSelectInform')}",
				  data: {
				      id:ids.join(',')
				  },
				  dataType: "json",
				  success: function(data){
					  if(data.status==0){
		                Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
		                        location.reload();
		                    }});
					  }else{
	                    Plugins.closeWindow();
						Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
					  }
				  }
			});
		}})
	   })
	   //批量未处理
	   $('body').on('click','.hideAll',function(){
		   var ids = [];
		   $('.chk').each(function(){
			   if($(this).prop('checked'))ids.push($(this).val());
		   })
		   if(ids.length == 0){
	 		   Plugins.Tips({title:'信息提示',icon:'error',content:'请选择要处理的举报记录!',timeout:1000});
	  		   return;
		   }
        Plugins.confirm({title:'信息提示',content:'您确定使所选举报为未处理状态吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
				  type: "POST",
				  url: "{:U('Posts/hideSelectInform')}",
				  data: {
				      id:ids.join(',')
				  },
				  dataType: "json",
				  success: function(data){
					  if(data.status==0){
		                    Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
		                        location.reload();
		                    }});
					  }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
					  }
				  }
				});
			 }});
	   })
	   //批量已处理
	   $('body').on('click','.showAll',function(){
		   var ids = [];
		   $('.chk').each(function(){
			   if($(this).prop('checked'))ids.push($(this).val());
		   })
		   if(ids.length == 0){
	 		   Plugins.Tips({title:'信息提示',icon:'error',content:'请选择要处理的举报记录!',timeout:1000});
	  		   return;
		   }
        Plugins.confirm({title:'信息提示',content:'您确定使所选举报为已处理状态吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
					  type: "POST",
					  url: "{:U('Posts/showSelectInform')}",
					  data: {
					       id:ids.join(',')
					  },
					  dataType: "json",
					  success: function(data){
						  if(data.status==0){
		                    Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
		                        location.reload();
		                    }});
						  }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
						  }
					  }
					});
			 }});
	   })
	   //删除单个举报记录
	   $('body').on('click','.del',function(){
		   var id=$(this).attr('data-id');
	   Plugins.confirm({title:'信息提示',content:'您确定要删除该举报记录吗?',okText:'确定',cancelText:'取消',okFun:function(){
		   Plugins.closeWindow();
		   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			   $.ajax({
					  type: "POST",
					  url: "{:U('Posts/delInform')}",
					  data: {
					      id:id
					  },
					  dataType: "json",
					  success: function(data){
						  if(data.status==0){
							Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
						    location.reload();
						}});
							  
						  }else{
						Plugins.closeWindow();
						Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
						  }
					  }
				});
			}})
		 
	   })
	   
	   $('.selectAll').on('click',function(){
		   var status=$(this).attr('data-status');
		   if(status==0){
			   $(this).attr('data-status',1);
			   $('.delid').each(function(){
				   $(this).prop('checked',true);
				   })
		   }else{
			   $(this).attr('data-status',0);
			   $('.delid').each(function(){
				   $(this).prop('checked',false);
				   })
		   }
	   })
	   //显示隐藏举报
	   $('body').on('dblclick','.isShow',function(){
		   var _this=$(this);
		   var text=$(this).text();
		   var status=0;
		   if(text=='否'){
			   status=1;
			   text="是";
		   }else{
			   status=0;
			   text="否";
		   }
		   var id=$(this).attr('data-id');
		   $.ajax({
				  type: "POST",
				  url: "{:U('Posts/informHide')}",
				  data: {
				      id:id,
				      status:status
				  },
				  dataType: "json",
				  success: function(data){
					  if(data.status==0){
						  layer.msg('操作成功');
						  $(_this).text(text);
						  
					  }else{
						  layer.msg('操作失败');
					  }
				  }
				});
	   })
	
   
   </script>
</html>